package algorithm;

import java.util.*;

public class StackProblem {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            // 栈 字母依次入栈，入栈前这个一个字母是否和栈顶相同，相同则移除栈顶
            String s = in.next();
            Stack<Character> stack = new Stack<>();
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (stack.empty()) {
                    stack.push(c);
                } else if (stack.peek() == c) {
                    stack.pop();
                } else {
                    stack.push(c);
                }
            }
            for (int i = 0; i < stack.size(); i++) {
                System.out.print(stack.get(i));
            }
        }
    }
}
